Socket
Socket
Sign inDemoInstall

keycode

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keycode

Convert between keyboard keycodes and keynames and vice versa.


Version published
Weekly downloads
1M
decreased by-1.48%
Maintainers
1
Weekly downloads
 
Created

What is keycode?

The keycode npm package is a utility for converting between keyboard key codes and their corresponding key names. It simplifies the process of handling keyboard events by providing easy-to-use functions for key code and key name conversions.

What are keycode's main functionalities?

Convert Key Code to Key Name

This feature allows you to convert a key code to its corresponding key name. For example, the key code 13 corresponds to the 'Enter' key.

const keycode = require('keycode');
const keyName = keycode(13); // 'enter'
console.log(keyName);

Convert Key Name to Key Code

This feature allows you to convert a key name to its corresponding key code. For example, the key name 'enter' corresponds to the key code 13.

const keycode = require('keycode');
const keyCode = keycode('enter'); // 13
console.log(keyCode);

Handle Keyboard Events

This feature allows you to handle keyboard events by converting the event object to a key name. This can be useful for logging or handling specific key presses in your application.

const keycode = require('keycode');
document.addEventListener('keydown', (event) => {
  const keyName = keycode(event);
  console.log(`Key pressed: ${keyName}`);
});

Other packages similar to keycode

Keywords

FAQs

Package last updated on 15 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc